<template>
  <div class="main-box">
    <!-- <el-button
      type="primary"
      size="mini"
      icon="el-icon-connection"
      style="margin-bottom:15px"
      class="add four"
      @click="allRestore"
    >批量恢复</el-button> -->
    <BaseTable :request="request" @selection-change="handleSelectionChange">
      <!-- <el-table-column
        type="selection"
        width="55"
      /> -->
      <el-table-column prop="id" label="ID" width="100px" />
      <el-table-column prop="title" :label="$t('内容名称')" />
      <el-table-column prop="table_name" :label="$t('内容类型')" />
      <!-- <el-table-column prop="title" label="删除时间" /> -->
      <el-table-column prop="name" :label="$t('操作人')" />
      <el-table-column
        :label="$t('操作')"
        fixed="right"
        align="right"
        width="100px"
      >
        <template slot-scope="scope">
          <RestoreBtn @click="restore(scope.row)" />
          <DelBtn @click="del(scope.row)" />
        </template>
      </el-table-column>
    </BaseTable>
  </div>
</template>

<script>
import recycleApi from '@/api/recycle'
export default {
  data() {
    return {
      request: recycleApi.recycleList,
      ids: []
    }
  },

  methods: {
    // 多选
    handleSelectionChange(val) {
      this.ids = val
    },
    // 回收站列表
    getList(type) {
      this.$refs.baseTable.getList(type)
    },
    // 还原
    restore(row) {
      recycleApi.recycleRestore({ id: row.id }).then(res => {
        if (res.code == 0) {
          this.$message.success(res.msg)
          this.getList()
        }
      })
    },
    // 批量还原
    allRestore() {
      recycleApi.recycleRestoreAll({ ids: this.ids }).then(res => {
        if (res.code == 0) {
          this.$message.success(res.msg)
          this.getList()
        }
      })
    },
    // 删除
    del(row) {
      recycleApi.recycledel({ id: row.id }).then(res => {
        if (res.code == 0) {
          this.$message.success(res.msg)
          this.getList()
        }
      })
    }
  }
}
</script>

<style scoped></style>
